﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections.Generic;


/// <summary>
/// Summary description for Director
/// </summary>
public class Director
{
    SqlConnection conn = Utils.getDBConnection();

    private int movie_dir_ID = 0;
    private string fname = null;
    private string lname = null;
    private string name = null;


    public Director()
    {
        //
        // TODO: Add constructor logic here

    }

    /// <summary>
    /// /List of all getters and setter for the customer class
    /// </summary>
    public int MovieDirID
    {
        get { return movie_dir_ID; }
        set { movie_dir_ID = value; }
    }

    public string DirFName
    {
        get { return fname; }
        set { fname = value; }
    }

    public string DirLName
    {
        get { return lname; }
        set { lname = value; }
    }

    public string DirName
    {
        get { return name; }
        set { name = value; }
    }


    /// <summary>
    /// Method to get director details 
    /// </summary>
    /// <param name="user">search text</param>
    /// <returns>Movies object</returns>

    public List<Director> getDirector()
    {

        //prepare SQL call
        SqlCommand storedProcCommand = new SqlCommand("dbo.mov_getDirectorListing", conn);
        storedProcCommand.CommandType = System.Data.CommandType.StoredProcedure;
        // storedProcCommand.Parameters.AddWithValue("@searchtext", text);
        conn.Open();

        //exec SQL
        SqlDataReader reader = storedProcCommand.ExecuteReader();
        List<Director> results = new List<Director>();


        //check 
        while (reader.Read())
        {
            Director dr = new Director();
            dr.MovieDirID = (int)reader["movie_dir_ID"];
            dr.DirFName = reader["movie_dir_fname"].ToString();
            dr.DirLName = reader["movie_dir_lname"].ToString();
            dr.DirName = reader["movie_dir_name"].ToString();
            results.Add(dr);
        }

        //clean-up
        reader.Close();
        conn.Close();
        return results;
    }





}